package com.atguigu.lease.web.admin.custom.converter;

import com.atguigu.lease.model.enums.ItemType;
import com.atguigu.lease.model.enums.ReleaseStatus;
import org.springframework.context.annotation.Bean;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class ConverterApartmentById implements Converter<String, ReleaseStatus> {
    @Override
    public ReleaseStatus convert(String status) {
        ReleaseStatus[] arr = ReleaseStatus.values();
        //循环你枚举数组里的每一个状态
        for (ReleaseStatus s : arr) {
            //如果你获取的数字和前端转换过来的数字是一样的,那么就返回枚举类型的值
            if (s.getCode().equals(Integer.valueOf(status))){
                return s;
            }

        }
        throw new RuntimeException("发布状态异常");
    }
}
